#ifndef SINGLETONCLASS_H
#define SINGLETONCLASS_H

/* 单例宏不具备普遍性，因为有的构造函数可能并不一样,而且静态变量也需要在外面 */
/**
 * use info
 * .h Singleton(MyClass)
 * .cpp in front of cpp file,Singleton_IMPL(MyClass)
*/
#define Singleton(ClassName) \
    private: \
    static ClassName *_instance; \
    ClassName(const ClassName &) = delete; \
    ClassName &operator =(const ClassName &) = delete; \
    ClassName(){} \
    public: \
    static ClassName *getInstance() { \
    if (!_instance) \
    _instance = new ClassName; \
    return _instance; \
    }

#define Singleton_IMPL(ClassName) \
    ClassName *ClassName::_instance=nullptr;


#endif // SINGLETONCLASS_H
